<template>
  <div class="base-platform">
    <div class="title"><span class="title-text">基础平台板块</span></div>
    <div class="platform-total">
      <span class="total-text">平台累计PV量(人次)</span>
      <count-to
        class="total-number"
        :startVal="0"
        :endVal="pv"
        :duration="1000"
      ></count-to>
    </div>
    <div class="data-display">
      <div class="data-item">
        <p class="item-title">
          <span class="border"></span>
          <count-to
            class="item-number"
            :startVal="0"
            :endVal="compCount"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">认证企业数(家)</p>
      </div>
      <div class="data-item">
        <p class="item-title">
          <span class="border"></span>
          <count-to
            class="item-number"
            :startVal="0"
            :endVal="userCount"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">注册用户数(个)</p>
      </div>
      <div class="data-item">
        <p class="item-title">
          <span class="border"></span>
          <count-to
            class="item-number"
            :startVal="0"
            :endVal="studentCount"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">小程序用户数(个)</p>
      </div>
    </div>
    <div class="chart-box">
      <div class="chart-legend">
        <span class="legend"></span><span class="text">平台累计用户数</span>
      </div>
      <Echart id="base-chart" :options="option" height="183px" width="100%" />
    </div>
  </div>
</template>
  
<script setup>
import { onMounted, reactive, ref } from "vue";
import Echart from "@/components/echart/index.vue";
import CountTo from "@/components/vueCountTo/vue-countTo.vue";
import { ajax } from "@/store/service";
import { dataGroup } from "@/utils";
import opt from "./option";

const option = reactive({ ...opt });

const pv = ref(0);
const compCount = ref(0);
const userCount = ref(0);
const studentCount = ref(0);

const init = async () => {
  const [res] = await ajax.basePlatform();
  pv.value = res.pv;
  compCount.value = res.compCount;
  userCount.value = res.userCount;
  studentCount.value = res.studentCount;
  const chart = dataGroup(res.chart.slice(5));
  option.xAxis.data = chart.x;
  option.series[0].data = chart.y;
  option.series[1].data = chart.y;
  option.series[2].data = chart.y;
};

onMounted(() => {
  init();
});
</script>

<style  lang='scss'>
.base-platform {
  width: 483px;
  height: 452px;
  .title {
    width: 483px;
    height: 80px;
    background-image: url("@/assets/bigscreen2/小标题背景.png");
    padding-top: 15px;
    box-sizing: border-box;

    .title-text {
      display: block;
      margin-left: 68px;
      font-size: 22px;
      font-family: JLinXin;
      font-weight: 600;
      line-height: 22px;
      background: #fffde8 linear-gradient(180deg, #e8feff 40%, #00a9ff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }
  .platform-total {
    height: 94px;
    margin-left: 17px;
    display: flex;
    align-items: center;
    background-image: url("@/assets/bigscreen2/累计PV.png");
    background-repeat: no-repeat;
    .total-text {
      margin-left: 95px;
      font-size: 18px;
      // font-family: PangMenZhengDao-3, PangMenZhengDao;
      font-weight: normal;
      color: #ffffff;
    }
    .total-number {
      font-size: 28px;
      // font-family: D-DIN-PRO-Heavy, D-DIN-PRO;
      font-weight: 800;
      color: #ffffff;
      line-height: 46px;
      letter-spacing: 2px;
      padding-left: 10px;
    }
  }
  .data-display {
    height: 98px;
    margin-left: 17px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    .data-item {
      margin-top: 18px;
      .item-title {
        color: #ffffff;
        vertical-align: top;
        display: flex;
        align-items: center;
        margin-bottom: 4px;
        .border {
          display: inline-block;
          width: 3px;
          height: 13px;
          background: #289583;
          border-radius: 2px;
          margin-right: 7px;
        }
      }
      .item-number {
        font-size: 26px;
        font-family: D-DIN-PRO-Heavy, D-DIN-PRO;
        font-weight: 800;
        color: #ffffff;
        line-height: 26px;
        margin-left: 7px;
      }
      .key {
        font-size: 14px;
        font-family: SourceHanSansCN-Medium, SourceHanSansCN;
        font-weight: 500;
        color: #ffffff;
        line-height: 21px;
        opacity: 0.8;
        margin-left: 15px;
      }
    }
  }
  .chart-box {
    color: #fff;
    height: 183px;
    position: relative;
    .chart-legend {
      height: 14px;
      position: absolute;
      right: 0;
      display: flex;
      align-items: center;
      // transform: translateY(-50%);
      .legend {
        width: 16px;
        height: 8px;
        background: #00f9d1;
        display: block;
        margin-top: 1px;
      }
      .text {
        height: 14px;
        font-size: 12px;
        margin-left: 4px;
        font-family: SourceHanSansCN-Regular, SourceHanSansCN;
        color: #fffde8;
      }
    }
  }
}
</style>./option